<?php
    $subCategories = Category::model()->findAll('is_submenu = 1 ORDER BY `order` ASC, category_id DESC');
?>
<!-- BEGIN PAGE CONTAINER-->
<div class="container-fluid">
    <!-- BEGIN PAGE HEADER-->
    <div class="row-fluid">
        <div class="span12">
            <!-- BEGIN PAGE TITLE & BREADCRUMB-->
            <h3 class="page-title">
                Quản lý Sub menu sản phẩm
            </h3>
            <ul class="breadcrumb">
                <li>
                    <i class="icon-home"></i>
                    <a href="/admin/shop/admin">Trang chủ</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li>
                    <a href="#">Menu sản phẩm</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li><a href="#">Thêm mới Sub Menu</a></li>
            </ul>
            <!-- END PAGE TITLE & BREADCRUMB-->
        </div>
    </div>
    <!-- END PAGE HEADER-->
    <!-- BEGIN PAGE CONTENT-->
    <div class="row-fluid">
        <div class="span12">
            <!-- BEGIN EXAMPLE TABLE PORTLET-->
            <div class="portlet box light-grey">
                <div class="portlet-title">
                    <h4><i class="icon-plus-sign"></i>Thêm mới Sub Menu sản phẩm</h4>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body form">
                    <!-- BEGIN FORM-->
                    <form action="/admin/subcategory/create" method="post" class="horizontal-form">
                        <div class="row-fluid">
                            <div class="span6 ">
                                <div class="control-group">
                                    <label class="control-label" for="firstName">Tên Sub menu</label>
                                    <div class="controls">
                                        <input type="text" id="firstName" class="m-wrap span12" placeholder="" name="Category[title]">
                                    </div>
                                </div>
                            </div>
                            <!--/span-->

                        </div>
                        <!--/row-->

                        <div class="form-actions">
                            <button type="submit" class="btn blue"><i class="icon-ok"></i> Lưu</button>
                            <button type="reset" class="btn">Hủy</button>
                        </div>
                    </form>
                    <!-- END FORM-->
                </div>
            </div>
            <!-- END EXAMPLE TABLE PORTLET-->
        </div>
    </div>

    <div class="row-fluid">
        <div class="span12">
            <!-- BEGIN EXAMPLE TABLE PORTLET-->
            <div class="portlet box light-grey">
                <div class="portlet-title">
                    <h4><i class="icon-bookmark-empty"></i>Danh mục Sub Menu</h4>
                    <div class="tools">
                        <a href="javascript:;" class="collapse"></a>
                    </div>
                </div>
                <div class="portlet-body">
                    <div class="clearfix">
                        <!--
                        <div class="btn-group pull-right">
                            <button class="btn red" type="button">
                                Xóa <i class="icon-trash"></i>
                            </button>
                        </div>
                        -->
                    </div>
                    <form name="frm-subcategory" id="frm-subcategory" action="/admin/subcategory/saveorder" method="post">
                    <table class="table table-striped table-bordered table-hover" id="sample_1">
                        <thead>
                        <tr>
                            <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#sample_1 .checkboxes" /></th>
                            <th>Tên Sub menu</th>
                            <th width="120">Sắp xếp <a href="javascript:void(0);"><i class="icon-save"></i></a></th>
                            <th style="width:100px"></th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php if(!empty($subCategories)) {
                            $i = 1;
                            foreach($subCategories as $cat) {?>
                                <tr class="odd gradeX">
                                    <td><input type="checkbox" class="checkboxes" value="<?php echo $i; $i++?>" /></td>
                                    <td><?php echo $cat->title;?></td>
                                    <td>
                                        <a class="btn grey mini" href="javascript:void(0)"><i class="icon-circle-arrow-down" rel="<?php echo $cat->category_id?>"></i></a>
                                        <a class="btn grey mini" href="javascript:void(0)"><i class="icon-circle-arrow-up" rel="<?php echo $cat->category_id?>"></i></a>
                                        <input style="width:30px" name="order[]" id="order<?php echo $cat->category_id?>" type="text" value="<?php echo $cat->order?>">
                                        <input name="id[]" type="hidden" value="<?php echo $cat->category_id?>">
                                    </td>
                                    <td>
                                        <a class="btn green mini" href="/admin/subcategory/update/id/<?php echo $cat->category_id;?>"><i class="icon-pencil icon-white"></i></a>
                                        <a class="btn red mini" href="/admin/subcategory/delete/id/<?php echo $cat->category_id;?>"><i class=" icon-remove icon-white"></i></a>
                                    </td>
                                </tr>
                        <?php }
                        }
                        ?>

                        </tbody>
                    </table>
                    </form>
                </div>
            </div>
            <!-- END EXAMPLE TABLE PORTLET-->
        </div>
    </div>
    <!-- END PAGE CONTENT-->
</div>
<!-- END PAGE CONTAINER-->